package com.whfc.openapi.api.gis;

import com.whfc.common.result.ListData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.emp.dto.GisEmpDTO;
import com.whfc.emp.service.AppEmpBoardService;
import com.whfc.fuum.dto.open.OpenApiClientDTO;
import com.whfc.mach.dto.GisMachDTO;
import com.whfc.mach.service.AppMachBoardService;
import com.whfc.openapi.constant.OpenApiConst;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/10/21 11:40
 */
@RestController
@RequestMapping(value = "open/api/gis")
public class GisDataController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @DubboReference(interfaceClass = AppEmpBoardService.class, version = "1.0.0")
    private AppEmpBoardService appEmpBoardService;

    @DubboReference(interfaceClass = AppMachBoardService.class, version = "1.0.0")
    private AppMachBoardService appMachBoardService;

    @GetMapping("mach/data")
    public Result getMachData(@RequestAttribute(OpenApiConst.OPENAPI_CLIENT) OpenApiClientDTO openApiClientDTO) {
        logger.info("gis获取设备信息,client:[{}]", openApiClientDTO);
        List<GisMachDTO> gisMachDTOList = appMachBoardService.getGisMachData(openApiClientDTO.getDeptId());
        ListData<GisMachDTO> listData = new ListData<>(gisMachDTOList);
        return ResultUtil.success(listData);
    }

    @GetMapping("emp/data")
    public Result getEmpData(@RequestAttribute(OpenApiConst.OPENAPI_CLIENT) OpenApiClientDTO openApiClientDTO) {
        logger.info("gis获取人员信息,client:[{}]", openApiClientDTO);
        List<GisEmpDTO> gisEmpDTOList = appEmpBoardService.getGisEmpData(openApiClientDTO.getDeptId());
        ListData<GisEmpDTO> listData = new ListData<>(gisEmpDTOList);
        return ResultUtil.success(listData);
    }
}
